//
//  FirstLoginViewController.m
//  carcareIOS
//
//  Created by tianxing on 16/2/25.
//  Copyright © 2016年 baozun. All rights reserved.
//

#import "FirstLoginViewController.h"
#import "LoginViewController.h"
#import "UserHelper.h"
#import "BaseWebViewController.h"

@interface FirstLoginViewController ()

@property (nonatomic ,strong)UIButton *loginBt;      // 登录
@property (nonatomic ,strong)UIButton *experienceBt; // 模拟体验
@property (nonatomic ,strong)UIButton *zeroRentBt;   // 0元租盒
@end

@implementation FirstLoginViewController

#pragma mark --- View Live Circle


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    // 加载基本界面
    [self setUpBaseView];
    
}

#pragma  mark ---  业务逻辑代码
- (void)setUpBaseView{
  // 颜色的渐变效果
    
  UIImageView *bgImage = [Factory imageViewWithFrame:CGRectMake(0, 0, __MAIN_WIDTH, __MAIN_HEIGHT) image:ImageNamed(@"login_bg") onView:self.view];
  bgImage.contentMode = UIViewContentModeScaleToFill;
    
    // logo 和 字体的的设置
    UIImage *login = ImageNamed(@"login_logo");
    
    UIImageView *imageView = [Factory imageViewWithCenter:CGPointMake(self.view.centerX, 110) image:login onView:self.view];
    //用车挣抵车险
    [Factory imageViewWithCenter:CGPointMake(self.view.centerX, imageView.bottom + 60) image:ImageNamed(@"login_slogan") onView:self.view];
    
    // 已有盒子用户登录
    __weak __typeof(self) wself = self;
    
    UIImageView *buttonImage = [Factory imageViewWithCenter:CGPointMake(self.view.centerX, self.view.bottom - 98) image:ImageNamed(@"login_botton") onView:self.view];
    buttonImage.width = __MAIN_WIDTH - 32 * __MAIN_RATIO_375;
    buttonImage.left =  16 * __MAIN_RATIO_375;
    buttonImage.contentMode = UIViewContentModeScaleToFill;
    
    self.loginBt = [[UIButton buttonWithFrame:CGRectMake(22 * __MAIN_RATIO_375, self.view.bottom - 120, __MAIN_WIDTH - 44 * __MAIN_RATIO_375, 44) title:@"进入车挣" textColor:COLOR_HEXSTRING(@"#FEFEFE") font:FONT_BUTTON click:^{
        LoginViewController *loginVC = [[LoginViewController alloc] init];
        [wself presentViewController:[UINavigationController navigationControllerWithRootViewController:loginVC] animated:YES completion:^{}];
        [UmengMgr event:ICZ_Login];
    }] setupOnView:self.view];
    
    self.loginBt.titleLabel.font = FONT_DEFAULT_Light(17);

    // 模拟体验
    self.experienceBt = [[UIButton buttonWithFrame:CGRectMake(self.loginBt.left + 2 * __MAIN_RATIO_375, self.loginBt.bottom + 16, (self.loginBt.width - 20 * __MAIN_RATIO_375) / 2, self.loginBt.height) title:@"模拟体验" textColor:COLOR_HEXSTRING(@"#BCDAFA") font:FONT_BUTTON click:^{
        [UmengMgr event:ICZ_Try];
        [UserHelper loginByVisiterSuccess:^{
            
            USERINFO.isLogin = YES;
            [SCREEN showMainScreen];
            
            [UserHelper visiterShowBuyCar];

        } fail:^{
        }];
    }] setupOnView:self.view];

    self.experienceBt.titleLabel.font = FONT_DEFAULT_Light(17);
    self.experienceBt.layer.borderWidth = 1;
    self.experienceBt.layer.borderColor = COLOR_HEXSTRING(@"#BCDAFA").CGColor;
    self.experienceBt.clipsToBounds = YES;
    self.experienceBt.layer.cornerRadius = 2;

    
    // 0元租盒
    self.zeroRentBt = [[UIButton buttonWithFrame:CGRectMake(self.experienceBt.right + 18 * __MAIN_RATIO_375,self.loginBt.bottom + 16, (self.loginBt.width - 20 * __MAIN_RATIO_375) / 2, self.loginBt.height) title:@"0元租盒" textColor:COLOR_HEXSTRING(@"#BCDAFA") font:FONT_BUTTON click:^{
        [UmengMgr event:ICZ_GetFreeEquiptment];
        BaseWebViewController * webVC = [[BaseWebViewController alloc]initWithURL:@"http://m.ichezheng.com/mobile/mobile.html#/entry/select"];
        [webVC navSetupLeftTitle:@"关闭" action:^{
            [webVC dismissViewControllerAnimated:YES completion:nil];
        }];
        webVC.title = @"0元租盒";
        [wself presentViewController:[UINavigationController navigationControllerWithRootViewController:webVC] animated:YES completion:nil];
    }] setupOnView:self.view];
    self.zeroRentBt.titleLabel.font = FONT_DEFAULT_Light(17);
    self.zeroRentBt.layer.borderWidth = 1;
    self.zeroRentBt.layer.borderColor = COLOR_HEXSTRING(@"#BCDAFA").CGColor;
    self.zeroRentBt.clipsToBounds = YES;
    self.zeroRentBt.layer.cornerRadius = 2;
    
}


@end
